package com.jamal2362.apktool.fragment;

import android.app.Fragment;
import android.content.pm.PackageInfo;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import com.jamal2362.apktool.util.MUtil;
import com.jamal2362.apktool.util.Settings;
import android.app.Activity;
import com.jamal2362.apktool.util.TextUtil;

public class HelpFragment extends Fragment
{

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
	{
		return new WebView(inflater.getContext());
	}

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState)
	{
		super.onViewCreated(view, savedInstanceState);
		Activity act = getActivity();
		String mVersion = "1";
		int mCodeName = 1;
		try
		{
			PackageInfo pInfo = act.getPackageManager().getPackageInfo(act.getPackageName(), 0);
			mCodeName = pInfo.versionCode;
			mVersion = pInfo.versionName;
		}
		catch (Exception e)
		{}
		boolean lightTheme = Settings.getb(act, "light_theme", true);
		String lang = MUtil.getCountry(act);
		// TextUtil.st(act, lang);
		WebView web = (WebView) view;
		if (!lightTheme) web.setBackgroundColor(Color.TRANSPARENT);
		web.getSettings().setJavaScriptEnabled(true);
		web.loadUrl("file:///android_asset/about" + (lang.equals("de") ? "_de" : "") + ".html?theme=" + (lightTheme ? "light" : "dark") + "&version=" + mVersion + "(" + mCodeName + ")&arch=" + Settings.sysArch);
	}
}
